<?php
include('../variables.php');

$lang_file = "../languages/$lang.php";
include($lang_file); 

$id = $_GET['id'];

$connect = mysql_connect($host,$username,$password);
if (!$connect) {
   die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die( "Unable to select database");

	// generate and execute query
	$query = "SELECT * FROM files WHERE id = '$id'";
	$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());

	// if a result is returned
	if (mysql_num_rows($result) > 0)
	{
  // turn it into an object
  $row = mysql_fetch_object($result);

?>
<html>
<head>
	<link href="../css/default.css" rel="stylesheet" type="text/css" />
<title><? echo $lang_delete_product;?></title>
</head>
<body>
<?php include("../includes/header.php"); ?>

<?

$filename = $row->filename;

if (!$filename == "")
{
$myFile = '../myfiles/' . $filename;
unlink($myFile);
}

$query = "DELETE FROM files WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());

// close database connection
mysql_close($connect);

// print result
echo "<div class=\"alert\">$lang_delete_succesful.</div>";
}
?>

</body>
</html>